package com.gitee.proxy;

import com.gitee.proxy.server.HttpProxyServer;

public class NettyHttpProxyApplication {

    public static void main(String[] args) {
        int port = 9999;
        if (args.length > 0) {
            port = getServerPort(args, port);
        }
        HttpProxyServer proxyServer = new HttpProxyServer();
        proxyServer.start(port);
    }

    private static int getServerPort(String[] args, int defaultPort) {
        for (int i = 0; i < args.length; i++) {
            if (args[i].startsWith("--server.port=")) {
                String port = args[i].split("=")[1];
                return Integer.parseInt(port);
            }
        }
        return defaultPort;
    }
}
